<template>
    <div>
        <h2>房号添加</h2>
        <table class="table table-bordered">
            <tbody>
                <tr>
                    <td align="right">房号名称</td>
                    <input type="text" v-model="queryInfo.roomName" />
                </tr>
                <tr>
                    <td align="right">备注</td>
                    <textarea v-model="queryInfo.roomDesc" cols="50" rows="5"></textarea>
                </tr>
                <tr>
                    <td align="right">房号状态</td>
                    <input type="radio" v-model="queryInfo.state" :value="1" />上架
                    <input type="radio" v-model="queryInfo.state" :value="0" />下架
                </tr>
                <tr>
                    <td align="right">手机号</td>
                    <input type="text"  v-model="queryInfo.phone"/>
                </tr>
                <tr>
                    <td align="right"></td>
                    
                </tr><input type="button" value="添加" @click="ok" />
            </tbody>
        </table>
    </div>
</template>


<script setup lang="ts">
import { ref, reactive, onMounted } from 'vue'
import { useRouter , useRoute } from 'vue-router'
import axios from 'axios';
let router = useRouter();   
let route = useRoute();
let queryInfo=reactive({
   
  roomName: "",
  roomDesc: " ",
  state: 1,
  phone: "",
})
let ok=()=>{
    if(queryInfo.roomName==""){
        alert("请输入房号")
        return
    }
    if(queryInfo.roomDesc==""){
        alert("请输入房号描述")
        return
    }
    if(queryInfo.phone==""){
        alert("请输入手机号")
        return
    }
    axios({
        method: 'post',
        url: '/api/RooomNumber/RoomAdd',
        data: queryInfo
    })
    .then((res)=>{
        console.log(res.data)
       if(res.data>0){
        alert("添加成功")
        router.push({path:"/RoomNumberList"})
       }
       else if(res.data==-1){
        alert("该房间号已存在")
       }
       else{
        alert("添加失败");
       }
    })
}
</script>

<style scoped>

</style>